#define _CRT_SECURE_NO_WARNINGS 1
#pragma warning(disable:6031)
#include<stdio.h>

int BF_start(char* a1, char* a2)
{
	int start = 0;
	int i = 0;
	int j = 0;
	while (a1[i] != '\0' && a2[j] != '\0')
	{
		if (a1[i] == a2[j])
		{
			i++;
			j++;
		}
		else
		{
			start++;
			i = start;
			j = 0;
		}
	}
	if (a2[j] == '\0')
		return start;
	else
		return 0;
}

int BF(char* a1, char* a2)
{
	int i = 0;
	int j = 0;
	while (a1[i] != '\0' && a2[j] != '\0')
	{
		if (a1[i] == a2[j])
		{
			i++;
			j++;
		}
		else
		{
			i = i-j+1;
			j = 0;
		}
	}
	if (a2[j] == '\0')
		return (i - j + 1);
	else
		return 0;
}

int main()
{
	char a1[] = { "cdcdef" };
	char a2[] = { "cde" };
	char a1[] = { "abcdef" };
	char a2[] = { "abc" };
	int point = BF(a1, a2);
	printf("%d ", point);
}